﻿ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogicUniversityBiz
{
    public class EditSupplierList
    {
        public void addSupplier(String supplierCode, String supplierName, String contactName, String phoneNo, String faxNo, String address)
        {
            using (LogicUniversityEntities en = new LogicUniversityEntities())
            {

                Supplier newSupplier = new Supplier();

                newSupplier.Supplier_Code = supplierCode;
                newSupplier.Supplier_Name = supplierName;
                newSupplier.Contact_Name = contactName;
                newSupplier.Ph_No = phoneNo;
                newSupplier.Fax_No = faxNo;
                newSupplier.Address = address;

                //en.AddToSupplier(newSupplier);
                en.AddToSuppliers(newSupplier);
                en.SaveChanges();
            }
        }

        public void updateSupplier(String supplierCode, String supplierName, String contactName, String phoneNo, String faxNo, String address)
        {
            using (LogicUniversityEntities en = new LogicUniversityEntities())
            {
                Supplier updateSupplier = en.Suppliers.First(i => i.Supplier_Code == supplierCode);

                updateSupplier.Supplier_Name = supplierName;
                updateSupplier.Contact_Name = contactName;
                updateSupplier.Ph_No = phoneNo;
                updateSupplier.Fax_No = faxNo;
                updateSupplier.Address = address;

                en.SaveChanges();
            }
        }
    }


}
